package com.xjk.web.controller.education;

import com.xjk.common.annotation.Log;
import com.xjk.common.core.controller.BaseController;
import com.xjk.common.core.domain.AjaxResult;
import com.xjk.common.core.page.TableDataInfo;
import com.xjk.common.enums.BusinessType;
import com.xjk.common.utils.poi.ExcelUtil;
import com.xjk.education.domain.EduCourseInformation;
import com.xjk.education.service.IEduCourseInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人课表查询Controller
 * 
 * @author xjk
 * @date 2024-08-01
 */
@RestController
@RequestMapping("/education/courseinformation")
public class EduCourseInformationController extends BaseController
{
    @Autowired
    private IEduCourseInformationService eduCourseInformationService;

    /**
     * 查询个人课表查询列表
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduCourseInformation eduCourseInformation)
    {
        startPage();
        List<EduCourseInformation> list = eduCourseInformationService.selectEduCourseInformationList(eduCourseInformation);
        return getDataTable(list);
    }

    /**
     * 导出个人课表查询列表
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:export')")
    @Log(title = "个人课表查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduCourseInformation eduCourseInformation)
    {
        List<EduCourseInformation> list = eduCourseInformationService.selectEduCourseInformationList(eduCourseInformation);
        ExcelUtil<EduCourseInformation> util = new ExcelUtil<EduCourseInformation>(EduCourseInformation.class);
        util.exportExcel(response, list, "个人课表查询数据");
    }

    /**
     * 获取个人课表查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(eduCourseInformationService.selectEduCourseInformationByDataId(dataId));
    }

    /**
     * 新增个人课表查询
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:add')")
    @Log(title = "个人课表查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduCourseInformation eduCourseInformation)
    {
        return toAjax(eduCourseInformationService.insertEduCourseInformation(eduCourseInformation));
    }

    /**
     * 修改个人课表查询
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:edit')")
    @Log(title = "个人课表查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduCourseInformation eduCourseInformation)
    {
        return toAjax(eduCourseInformationService.updateEduCourseInformation(eduCourseInformation));
    }

    /**
     * 删除个人课表查询
     */
    @PreAuthorize("@ss.hasPermi('education:courseinformation:remove')")
    @Log(title = "个人课表查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(eduCourseInformationService.deleteEduCourseInformationByDataIds(dataIds));
    }
}
